package com.platform.file.service.impl;

import com.platform.common.core.exception.ServiceException;
import com.platform.file.service.ISysFileService;
import com.platform.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;

/**
 * 本地文件存储
 *
 * @author mbtec
 */
@Service
public class LocalSysFileServiceImpl implements ISysFileService
{
    /**
     * 资源映射路径 前缀
     */
    @Value("${file.prefix}")
    public String localFilePrefix;

    /**
     * 域名或本机访问地址
     */
    @Value("${file.domain}")
    public String domain;

    /**
     * 上传文件存储在本地的根路径
     */
    @Value("${file.path}")
    private String localFilePath;

    /**
     * 本地文件上传接口
     *
     * @param file 上传的文件
     * @param type
     * @return 访问地址
     * @throws Exception
     */
    @Override
    public String upload(MultipartFile file, String serviceName, String type) throws Exception
    {
        String name = FileUploadUtils.upload(localFilePath, file);
        String url = domain + localFilePrefix + name;
        return url;
    }

    @Override
    public String uploadShareFile(MultipartFile file, String filePath) throws Exception {
        return "";
    }

    @Override
    public String uploadByBucketName(MultipartFile file, String serviceName, String cataloguePrefix, String bucketName) throws Exception {
        return null;
    }

    @Override
    public String uploadByBase64(String fileName,InputStream inputStream, String serviceName, String cataloguePrefix, String bucketName) throws Exception {
        return null;
    }

    @Override
    public String uploadByAsyncFileName(InputStream inputStream, String filePath, String contentType) throws Exception {
        return null;
    }

    @Override
    public String uploadByAsyncFileNameAndBucketName(InputStream inputStream, String filePath, String contentType, String bucketName) throws Exception {
        return null;
    }

    @Override
    public InputStream downLoadFile(String filePath) throws Exception {
        return null;
    }

    @Override
    public String uploadFile(String filePath, InputStream inputStream, String contentType) throws Exception {
        return null;
    }

    @Override
    public void deleteFile(String filePath) throws Exception {

    }

    @Override
    public InputStream downLoadFileNew(String bucketName, String filePath) throws Exception {
        return null;
    }
}
